<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>{$meta_title}</h2>
    </div>
    <form action="{:U('save')}" method="post" class="form-horizontal">
        <div class="form-item">
            <label class="item-label">班级名<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="name" value="{$data.name}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">固定教学计划<span class="check-tips">（表示有教学计划的教学方案，由老师自己定义教学内容的班级请勿勾选）</span></label>
            <div class="controls">
                <label class="checkbox-pretty inline">
                    <input type="checkbox" name="have_plan" id="have_plan" value="1" <php>if(1==$data['have_plan'])echo 'checked="checked"';</php> ><span>有固定教学计划</span>
                </label>
            </div>
        </div>
        <div class="form-item" id="div_class_time">
            <label class="item-label">课程周期<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" placeholder=" - " name="class_time_cycle" value="{$data.class_time_cycle}" id="class_time">
            </div>
        </div>
        <div class="form-item" id="div_start_time">
            <label class="item-label">开始日期<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="start_time" value="{$data.start_time}" id="start_time">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">最少人数<span class="check-tips">（班级开班最少人数）</span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="min_num" value="{$data.min_num}" onkeyup="clearNoNum(this);">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">最多人数<span class="check-tips">（班级最多承受人数）</span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="max_num" value="{$data.max_num}" onkeyup="clearNoNum(this);">
            </div>
        </div>

        <div class="form-item">
            <label class="item-label">上课频率<span class="check-tips"><notempty name="data.id">（在修改后第4天生效）</notempty></span></label>
            <volist name="weekarray" id="week" key="w">
            <div class="controls" style=" float: left;margin-right: 80px;">
                <label data-toggle="checkbox" class="checkbox-pretty inline " style="margin-right: 10px;">
                    <input type="checkbox" value="{$w}" name="week[]" <php>if(in_array($w,$data['week'])){echo 'checked';}</php> > <span>周{$week}</span>
                </label>
                <select id="hourse" name="hourse_{$w}">
                    <volist name="hourse" id="h">
                        <option value="{$h}" <php>if($h==$data['hourse_'.$w])echo 'selected="selected"';</php> >{$h}</option>
                    </volist>
                </select>点
                <select id="minute" name="minute_{$w}">
                    <option value="00" selected="selected" >00</option>
                    <option value="30" <php>if(30==$data['minute_'.$w])echo 'selected="selected"';</php>>30</option>
                </select>分
            </div>
            </volist>
        </div>
        <div style="clear:both;"></div>

        <div class="form-item" style="margin-top: 30px;">
            <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
        <input type="hidden"  name="id" value="{$data.id}" >
        <input type="hidden"  name="course_id" value="{$course.id}" >
    </form>
</block>

<block name="script">
    <script type="text/javascript">

        $("#have_plan").click(function(){
            if ($('#have_plan').is(':checked')) {
                $("#div_class_time").hide();
                $("#div_start_time").show();
            }else{
                $("#div_class_time").show();
                $("#div_start_time").hide();
            }
        });
        $(document).ready(function(){
            <eq name="data.have_plan" value="1">
                $("#div_class_time").hide();
                $("#div_start_time").show();
                <else/>
                $("#div_start_time").hide();
            </eq>
        });



        //日期时间范围
        laydate.render({
            elem: '#start_time'
            ,type: 'date'
        });
        laydate.render({
            elem: '#class_time'
            ,type: 'date'
            ,range: true
        });
        function clearNoNum(obj)
        {
            obj.value = obj.value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符
            obj.value = obj.value.replace(/^\./g,"");  //验证第一个字符是数字而不是.
            obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的.
            obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
        }
        //导航高亮
        highlight_subnav('{:U('Grade/index')}');
    </script>
</block>
